Skip to content

fix(engine): Let a walk leave the Dock it just stepped off - #365

Merged
omesser merged 1 commit into
mainfrom
fix/361-dock-walk
Sep 5, 2026
Merged

omesser merged 1 commit into
mainfrom
fix/361-dock-walk

Conversation

@omesser

@omesser omesser commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

Why

A Character can never get past the Dock. It climbs the near side, walks the
top, steps off the far end — and is caught by the side it just cleared, climbed
back up, and put back on the top to do it again. Everything beyond the Dock,
including the screen edge it was heading for, is unreachable for as long as the
app runs.

The Engine alone, Dock at x 400..600 on a 1000-wide display, held walk heading
left. Frame 73 is frame 0 again:

  0 Perched  x=534 y=700   on the Dock, walking left along the top
 70 Falling  x=400 y=700   steps off the left end
 72 Climbing x=336 y=701   caught by dock_side_reached at dock.x - EDGE_CLEARANCE
 73 Perched  x=464 y=700   dock_top_at puts it back on at dock.x + EDGE_CLEARANCE

Reported against BMO, which "hits the left display wall while still on the
dock, so it can't walk left, and never reaches the edge to climb up". The wall
is not the display's — it is the Dock's own side, a half-sprite out and nowhere
near the screen edge, which is why it looks like it bounces off nothing.

What changed

dock_side_reached learns which way the sprite is going. The Dock's side is a
wall for one moving into it and not for one moving away — the rule
wall_reached already keeps for a display edge, and states in its own doc
comment: "only while the sprite is moving into it. Every inner edge is
somewhere to cross rather than something to catch."
The Dock's side never got
it.

Strictly behind the Dock there is no reprieve, whichever way the sprite is
travelling: a real Dock is wide and the way out from under one is a long way
sideways, all of it unseen, which is what #176 decided. So the margin outside
the Dock's span is directional and the span itself is not.

The "behind" test is strict, so a sprite level with the Dock's own edge counts
as being in the margin and may leave. That is the position stepping off the top
lands on, and treating it as behind would keep the trap shut.

The accepted cost: a sprite coming to rest in the margin while moving away —
not walking, not thrown, just stopping there — stands overlapping the Dock's
edge by up to a half-sprite rather than being pushed clear. It takes a throw
that runs out of speed inside a band a half-sprite wide. That belongs to the
resting inset if it ever shows up, not to a wall in the middle of the floor.

How to verify

cargo test --workspace — 417, 212 and 18 pass. cargo clippy --workspace --all-targets -D warnings and cargo fmt --check are clean.

a_walk_off_the_dock_top_carries_on_past_it_rather_than_climbing_back holds a
walk off the Dock's top and asserts it reaches the display edge without ever
being put back on the Dock. Without the fix it fails at the fourth frame with
put back on the Dock it had just walked off: position (464, 700), Perched —
the loop itself.

The three tests pinning the behaviour this must not break all still pass
untouched: a_walk_into_the_dock_climbs_onto_it_rather_than_behind_it (#176),
a_sprite_dropped_behind_the_dock_climbs_out_onto_it, and
a_sprite_dropped_near_the_docks_right_end_climbs_out_that_side.

Traced end to end, the Character now patrols the whole display: off the Dock,
left to the screen edge at 0, climbs it, back across, climbs onto the Dock
when it walks into the side, off its right end, out to the right edge at 1000,
and back.

Notes

This bug is not #328's, though it was found while testing it. The same loop
runs on main with the fixed EDGE_CLEARANCE of 64 — leftmost point 336,
against 337 with #328's per-Character clearance. One point apart.

#328 and this both touch dock_side_reached, so whichever lands second needs a
trivial rebase: #328 adds a clearance parameter, this one adds velocity_x.
Independent otherwise, and both are based on main.

Closes #361

— Cursor agent, on @omesser's behalf.

@omesser
omesser force-pushed the fix/327-sprite-width-edge-clearance branch from cd8e8fb to 438af99 Compare September 5, 2026 16:17
@omesser
omesser changed the base branch from fix/327-sprite-width-edge-clearance to main September 5, 2026 16:32
The Dock's side caught a sprite moving away from it, climbed it back up and
put it on the top to step off again. Everything past the Dock was
unreachable.

Co-authored-by: Cursor <cursoragent@cursor.com>
@omesser
omesser merged commit f08c6ed into main Sep 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Dock is a one-way trap: a walk that steps off its top is put straight back on

1 participant